﻿// JScript File


function AssociateInteraction(owner)
{
    this.owner = owner;
    var xmldom = CreateXmlDOM();
    this.Interact = function(event)
    {            
        var aEvent = event ? event : window.event;        
        var sel = aEvent.srcElement ? aEvent.srcElement : aEvent.target;
        var pairIndex = 0;
        var curNode = sel.parentNode.parentNode;
        var Node = curNode.parentNode.firstChild;
        while (Node != curNode)
        {
            Node = Node.nextSibling;
            pairIndex++;
        }                                

        var userResponse = this.owner.xml.getElementsByTagName("userResponse")[0];        
        var vNode = this.owner.xml.getElementsByTagName("value")[pairIndex];                      
        
        
        if (!isMozilla)               
            vNode.text = sel.parentNode.previousSibling.firstChild.text + " " + sel.value;
        else
            vNode.textContent = sel.parentNode.previousSibling.firstChild.attributes.getNamedItem("text").value + " " + sel.value;
            
       // alert(SerializeXmlNode(this.owner.xml));
    }        
}
   
function AssociateRendering(owner)
{
    this.owner = owner;
    
    this.Render = function()
    {
        try
        {
            var html = "";
            html += TransformNode(this.owner.xml, "xslt/ItemHeader.xsl.aspx");            
            var itemBody = this.owner.xml.getElementsByTagName("itemBody")[0];            
            var p = itemBody.getElementsByTagName("p");            
            if (p.length > 0)
                html += SerializeXmlNode(p[0]);
            html += TransformNode(this.owner.xml, "xslt/AssociateInteraction.xsl");
            return html;
        }
        catch (e)
        {
            ShowMessage("Question rendering error:" + (e.message == undefined ? e : e.message));
        }
    }
}
